package org.jeecg.modules.online.p002a;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jeecg.common.exception.TuringBootException;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.online.cgform.utils.CgformUtil;
import org.jeecg.modules.online.cgreport.constant.CgReportConstant;
import org.jeecg.modules.online.cgreport.entity.OnlCgreportParam;

/* renamed from: org.jeecg.modules.online.a.b */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/a/b.class */
public class SqlParamsHandler<T> {

    /* renamed from: b */
    private final Map<String, Object> f92b;

    /* renamed from: c */
    private final List<T> f93c;

    /* renamed from: a */
    private final String f91a = "url";

    /* renamed from: d */
    private final Map<String, Object> f94d = new HashMap();

    /* renamed from: e */
    private final Map<String, Object> f95e = new HashMap();

    public SqlParamsHandler(Map<String, Object> map, List<T> list) {
        this.f92b = map;
        this.f93c = list;
    }

    /* renamed from: a */
    public String m534a(String str) {
        return m533a(str, ConditionHandler.f68b);
    }

    /* renamed from: b */
    public String m531b(String str) {
        return m533a(str, ConditionHandler.f67a);
    }

    /* renamed from: c */
    public String m530c(String str) {
        getClass();
        return m533a(str, "url");
    }

    /* renamed from: a */
    private String m533a(String str, String str2) {
        String str3;
        String replaceAll;
        if (this.f93c == null || this.f93c.isEmpty()) {
            return str;
        }
        for (T t : this.f93c) {
            String m535a = m535a(t);
            String m532b = m532b(t);
            Object obj = this.f92b.get("self_" + m535a);
            Object obj2 = this.f92b.get(m535a);
            String str4 = "";
            if (oConvertUtils.isNotEmpty(obj)) {
                str4 = obj.toString();
            } else if (oConvertUtils.isNotEmpty(obj2)) {
                str4 = obj2.toString();
            } else if (oConvertUtils.isNotEmpty(m532b)) {
                str4 = m532b;
            }
            String str5 = "${" + m535a + "}";
            if (str.indexOf(str5) > 0) {
                if (str4.startsWith(CgformUtil.f231C) && str4.endsWith(CgformUtil.f231C)) {
                    str4 = str4.substring(1, str4.length() - 1);
                }
                getClass();
                if ("url".equals(str2)) {
                    str = str.replace(str5, str4);
                } else {
                    String str6 = "_sql_param_" + m535a;
                    if (ConditionHandler.f67a.equals(str2)) {
                        str3 = ":" + str6;
                    } else {
                        str3 = "#{param." + str6 + "}";
                    }
                    Matcher matcher = Pattern.compile("'([^']*)\\$\\{" + m535a + "}([^']*)'").matcher(str);
                    if (matcher.find()) {
                        str4 = matcher.group(1) + str4 + matcher.group(2);
                        replaceAll = str.replace(matcher.group(0), str3);
                    } else {
                        replaceAll = str.replaceAll("'?\\$\\{" + m535a + "}'?", str3);
                    }
                    str = replaceAll;
                    this.f94d.put(str6, str4);
                }
            } else if (oConvertUtils.isNotEmpty(str4)) {
                if (t instanceof OnlCgreportParam) {
                    this.f94d.put(m535a, obj);
                    this.f92b.put(CgReportConstant.f498D + m535a, str4);
                } else if (t instanceof OnlCgreportParam) {
                    getClass();
                    if ("url".equals(str2)) {
                        str = str.replace(str5, "");
                    } else {
                        this.f95e.put(m535a, str4);
                    }
                }
            }
        }
        return str;
    }

    /* renamed from: a */
    private String m535a(T t) {
        if (t instanceof OnlCgreportParam) {
            return ((OnlCgreportParam) t).getParamName();
        }
        throw new TuringBootException("不支持的类型：" + t.getClass().getName());
    }

    /* renamed from: b */
    private String m532b(T t) {
        if (t instanceof OnlCgreportParam) {
            return ((OnlCgreportParam) t).getParamValue();
        }
        if (t instanceof OnlCgreportParam) {
            return ((OnlCgreportParam) t).getParamValue();
        }
        throw new TuringBootException("不支持的类型：" + t.getClass().getName());
    }

    public Map<String, Object> getSelfSqlParams() {
        return this.f94d;
    }

    public Map<String, Object> getOtherParams() {
        return this.f95e;
    }
}
